//
//  GameLayer.m
//  HelloWorldGame
//
//  Created by huji on 13-2-3.
//
//

#import "GameLayer.h"
#import "cocos2d.h"

@interface GameLayer ()
@property (nonatomic,retain) CCLabelTTF *_life;
@end

@implementation GameLayer
-(void)dealloc{
    self._life=nil;
    [super dealloc];
}
-(id)init{
    self = [super init];
    if (self) {
        CCLabelTTF *label = [CCLabelTTF labelWithString:@"life:" fontName:@"Marker Felt" fontSize:20];
        label.color = ccBLACK;
        label.position = ccp(25, self.contentSize.height-20);
        [self addChild:label];
        
        self._life = [CCLabelTTF labelWithString:@"100" fontName:@"Marker Felt" fontSize:20];
        self._life.color = ccBLUE;
        self._life.position = ccp(label.position.x+30, label.position.y);
        [self addChild:self._life];
        
    }
    return self;
}

-(void)showGameOver{
    CCLabelTTF *label = [CCLabelTTF labelWithString:@"GAME OVER" fontName:@"Marker Felt" fontSize:50];
    label.color = ccBLACK;
    label.position = ccp(self.contentSize.width/2, self.contentSize.height/2);
    [self addChild:label];
}

-(void)lifeValueChange:(float)life{
    self._life.string = [NSString stringWithFormat:@"%d",(int)life];
}

@end
